package com.hue.netty.day02.five;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/*
    客户端的编码器:
        客户端发送消息时将Long转为Byte
 */
public class ClientLongToByteHandler extends MessageToByteEncoder<Long> {
    //只有客户端发送long类型数据时才会被调用
    @Override
    protected void encode(ChannelHandlerContext ctx, Long msg, ByteBuf out) throws Exception {
        System.out.println("客户端调用了编码器");
        out.writeLong(msg);
    }
}
